﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Xml File Format</title>
</head>
<body>
<h1>Xml File Format</h1>
<p>OpenWPFChart Data XML format can store multiple series of 2D and 3D data points.</p>
    <p>OpenWPFChart Data XML document is validated against an XSD schema which is constructed dynamically 
basing on the contents of type mapping XML file (see below).</p>

<h2>Data XML document</h2>
<p>That's the example of XML data file contents:</p>
<pre>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;Items xmlns="urn:ItemData-schema"&gt;
	&lt;Points.Date.Double YName="y=temperature" XName="Month"&gt;
		&lt;Point x='2008-01-01' y='-20'/&gt;
		&lt;Point x='2008-02-01' y='-25'/&gt;
		...
		&lt;Point x='2008-12-01' y='-17'/&gt;
	&lt;/Points.Date.Double&gt;
	...
	&lt;Points.Double ItemType="ScatteredPoints" YName="Point Set 2"&gt;
		&lt;Point x="0.01" y="0.5"/&gt;
		...
		&lt;Point x="0.95" y="0.3"/&gt;
	&lt;/Points.Double&gt;
	...
&lt;/Items&gt;
</pre>

<p>The root content element is introduced by the Items tag. This element can contain any number of 
Point Series. In the sample snippet above two series are presented by their Points.Date.Double and 
Points.Double elements.</p>
<p>First series contains point of type Date in x dimension and Double in y dimension.</p>
<p>Second series contains point of type Double in both dimensions. Its ItemType is set to 
ScatteredPoints which indicates that the series represents the points cloud.</p>

<p>ItemType attribute of the series element tag expresses the intention on the series usage. E.g. 
the first would be treated by an application as the set of the sampled curve points and the second 
one as the set of points of the points cloud.</p>
<p>Every series element may have optional YName and XName attributes. The former corresponds to 
OpenWPFChart.Parts.ItemData.ItemName property and the latter can be used by an application to show 
the abscissas axis label.</p>
<p>Specific series element may imply additional restrictions: e.g. series with ItemType attribute 
missed or equal to the "SampledCurve" value requires its Point elements be ordered by abscissa (x) 
values.</p>
<p>A series element must contain one or more Point elements.</p>

<p>Every Point element must have x (for abscissa) and y (for ordinate) attributes.
Point coordinate values in the series must be convertible to the same base type.</p>
<p>Base type is determined by the first Point element attribute (x or y) values in the following manner:</p>
<ol>
<li>If the value can be converted to double, the base type is double.</li>
<li>If the value can be converted to DateTime, the base type is DateTime.</li>
<li>Otherwise the base type is string.</li>
</ol>

<p>Point series element is named according to the following patterns:</p>
<pre>          Pints.&lt;dimensions base type&gt;
         or
         Pints.&lt;x-dimension base type&gt;.&lt;y-dimension base type&gt;
         or
         Pints.&lt;x-dimension base type&gt;.&lt;y-dimension base type&gt;.&lt;z-dimension base type&gt;
</pre>
<p>The first pattern is applied to 2D data if both x and y dimensions have the same base type. 
    The thirs pattern is for 3D point series.</p>

<h2>Type Mapping XML document</h2>
<p>Base type strings come from mapping XML document which also maps Base type string values to XSD and
.NET type names. That's the example of mapping XML document:</p>
<pre> <?xml version="1.0" encoding="utf-8"?>&lt;Mappings xmlns="urn:ItemData-mapping"&gt;
	&lt;Mapping&gt;
		&lt;XAxis xsd-type="int" net-type="System.Double" type-string="Int"/&gt;
		&lt;YAxis xsd-type="int" net-type="System.Double" type-string="Int"/&gt;
	&lt;/Mapping&gt;
	&lt;Mapping&gt;
		&lt;XAxis xsd-type="double" net-type="System.Double" type-string="Double"/&gt;
		&lt;YAxis xsd-type="dateTime" net-type="System.DateTime" type-string="DateTime"/&gt;
	&lt;/Mapping&gt;
	...
	&lt;Mapping&gt;
		&lt;XAxis xsd-type="date" net-type="System.DateTime" type-string="Date"/&gt;
		&lt;YAxis xsd-type="date" net-type="System.DateTime" type-string="Date"/&gt;
	&lt;/Mapping&gt;
&lt;/Mappings&gt;
</pre>
<p>The first mapping in this example describes the point series element with "Points.Int" name. 
This element must contain points of XSD "int" type in both dimentions which will be converted to the 
System.Double values by the parser.</p>
<p>The second mapping describes the point series element with "Points.Double.DateTime" name. This element 
must contain points of XSD "double" type in x dimention and XSD "dateTime" type in y dimension. The former
will be converted to values of the System.Double type and the latter to value of System.DateTime type by 
the parser.</p>
<p>You could guess that the last mapping describes the point series element with "Points.Date" name.</p>

<p>All OpenWPFChart sample applications allowing to load data from xml files have mapping XML document
embedded as a Resource. Each defines data types acceptable for its application. For list of types allowed
see application directory Readme.txt.</p>

</body>
</html>
